<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="./axios.js"></script>
    <script>
        axios.defaults.baseURL = 'http://itcbc.com:3006'
        // 1.得到 Promise对象
        let a1 = axios.get('/api/province')
        let a2 = axios.get('/api/city', { params: { pname: '河南省' } })
        let a3 = axios.get('/api/county', { params: { pname: '河南省', cname: '信阳市' } })

        // 2.获取结果
        // 01.then....catch
        a1.then(result => {
            console.log(result.data)
            return a2
        }).then(result => {
            console.log(result.data)
            return a3
        }).then(result => {
            console.log(result.data)
        }).catch(error => {
            console.log(error)
        })

        // 02.async 和 await --- try....catch
        // async function fn() {
        //     let resultOne = await a1
        //     let resultTwo = await a2
        //     let resultThree = await a3
        //     console.log(resultOne.data,resultTwo.data,resultThree.data)
        // }
        // fn()

    </script>
</body>

</html>